function check(){
		
		var mrkObjNm= document.getElementById("markDate.mrkObjNm").value;
		var blngOrgNo= document.getElementById("markDate.blngOrgNo").value;
			if(mrkObjNm==null || mrkObjNm==""){
				alert("标记数据->标记对象名称必填");
			}else if(blngOrgNo==null || blngOrgNo==""){
				alert("请选择所属机构");
			}else{
					
			return true;
			}
		return false;	
		}
function sub(){
			if(check()){
				if(edit){
					if(getJingDu()!="0" && getWeiDu()!="0"){
					updateRow();
					}
				}else{
					if(getJingDu()!="0" && getWeiDu()!="0" && !isNaN(getJingDu()) && !isNaN( getWeiDu()) ){
						addRow();
					}
				}
				
				tijiao();
				document.getElementById("fm").submit();
		}
}

function adr(info,check){
		var contents = info;
		var alljwd = contents=="''"|contents==""?"":contents.split(",");　　		
		if(alljwd!=""){			
			for(var i = 0; i<alljwd.length;){
				var jwtb = document.getElementById("tb");
				var rowCount =jwtb.rows.length;
 		var row=jwtb.insertRow(jwtb.rows.length);
				//var info = alljwd[i].split(",");
				var cell1 = row.insertCell(0);
				cell1.innerHTML = rowCount ;
				var cell2 = row.insertCell(1);
					cell2.innerHTML = alljwd[i];
				var cell3 = row.insertCell(2);		
				    cell3.innerHTML = alljwd[i+1];
				var cell4 = row.insertCell(3);
				var ob1 = row.cells[1].innerHTML;
				var ob2 = row.cells[2].innerHTML;
				var html1 = "<a href='#' onclick='editRow("+ob1+","+ob2+","+row.rowIndex+")'><img src='../resource/img/ico/edit.png' class='edit_style' align='middle' alt='修改' title='修改'></img></a>";
				var html2= "&nbsp;&nbsp;    |&nbsp;&nbsp;    <a href='#' title='删除' onclick='removeRow("+row.rowIndex+")'><img src='../resource/img/ico/delete.png' class='delete_style' align='middle' alt='删除'></img></a>";
				if(check=="edit"){
					cell4.innerHTML = html1+html2;
				}else if(check=="detail"){
					cell4.innerHTML = html1;
				}
				
		
				i =  i+2;

			}
		}	
}
var selRow = null;
var edit = false;
function editRow(obj1,obj2,index){
		edit = true;
		var jwtb = document.getElementById("tb");
		selRow = jwtb.rows[index];
		
		var zbf = document.getElementById("zbf");
		if(zbf!=null ){
			zbf.innerHTML = "修改坐标信息";
		}
		
		setdfm("j",obj1);
		setdfm("w",obj2);
	}


	
function addRow(){
	  var jwtb = document.getElementById("tb");
　　　var row=jwtb.insertRow(jwtb.rows.length);
　    var rowCount =jwtb.rows.length;
		
	var cell1 = row.insertCell(0);
		cell1.innerHTML = rowCount - 1;
	var cell2 = row.insertCell(1);		
		cell2.innerHTML = getJingDu()=="0"?"0.000000":getJingDu();
			
	var cell3 = row.insertCell(2);		
		cell3.innerHTML = getWeiDu()=="0"?"0.000000":getWeiDu();	
	var cell4 = row.insertCell(3);
		var ob1 = row.cells[1].innerHTML;
		var ob2 = row.cells[2].innerHTML;
		cell4.innerHTML = "<a href='#' onclick='editRow("+ob1+","+ob2+","+row.rowIndex+")'><img src='../resource/img/ico/edit.png' class='edit_style' align='middle' alt='修改' title='修改'></img></a>&nbsp;&nbsp;    |    &nbsp;&nbsp;<a href='#' title='删除' onclick='removeRow("+row.rowIndex+")'><img src='../resource/img/ico/delete.png' class='delete_style' align='middle' alt='删除'></img></a>";
				
}
	
	function setdfm(jorw,html){
			html = html.toString();
			du = html.substring(0,html.indexOf('.'))==""?html:html.substring(0,html.indexOf('.'));
			sfen = (parseFloat(html)-parseFloat(du))*60;
			fen = sfen.toString().substring(0,sfen.toString().indexOf('.'));
			smiao = 60*(sfen-fen);
			miao = Math.round(parseFloat(smiao.toString().substring(0,smiao.toString().indexOf(".")+4))*100)/100;
		if(jorw=="j"){
			if(du<0 | fen<0 | miao<0){
				document.getElementById("jd").options[0].selected = false;
				document.getElementById("jd").options[1].selected = true;
			}else{
				document.getElementById("jd").options[0].selected = true;
				document.getElementById("jd").options[1].selected = false;
			}
			document.getElementById("jdu").value = Math.abs(isNaN(du)|du=="0"?"000":du);
			document.getElementById("jfen").value = Math.abs(isNaN(parseFloat(fen))|fen=="0"|""?"00":fen);
			document.getElementById("jmiao").value =Math.abs(isNaN(miao)|miao=="0"?"00.00":miao);
		}else{
			if(du<0 | fen<0 | miao<0){
				document.getElementById("wd").options[0].selected = false;
				document.getElementById("wd").options[1].selected = true;
			}else{
				document.getElementById("wd").options[0].selected = true;
				document.getElementById("wd").options[1].selected = false;
			}
			document.getElementById("wdu").value = Math.abs(isNaN(du)|du=="0"?"000":du);
			document.getElementById("wfen").value = Math.abs(isNaN(parseFloat(fen))|fen=="0"|""?"00":fen);
			document.getElementById("wmiao").value =Math.abs(isNaN(miao)|miao=="0"?"00.00":miao);
		}
	}
	
	function getJingDu(){
	    var zf = document.getElementById("jd").value; 
		var jdu = parseFloat(zf+document.getElementById("jdu").value);
		var jfen = parseFloat(zf+document.getElementById("jfen").value);
		var jmiao = parseFloat(zf+document.getElementById("jmiao").value);

		var jingdu = jdu+jfen/60+jmiao/3600;
		return jingdu.toString().substring(0,jingdu.toString().indexOf(".")+7);
	}
	
	function getWeiDu(){
		var zf = document.getElementById("wd").value;
		var wdu = parseFloat(zf+document.getElementById("wdu").value);
		var wfen = parseFloat(zf+document.getElementById("wfen").value);
		var wmiao = parseFloat(zf+document.getElementById("wmiao").value);		
		var weidu = wdu+wfen/60+wmiao/3600;
		return weidu.toString().substring(0,weidu.toString().indexOf(".")+7);
	}
	
	function updateRow(){
		var row = selRow;		
		if(row!=null){	
			row.style.background = "#FFFFFF";	
			row.cells[1].innerHTML = getJingDu().toString();
			row.cells[2].innerHTML = getWeiDu().toString();
			selRow = null;
		}
	}
	

	function removeRow(obj){
		if(check()){
			document.getElementById("tb").deleteRow(obj); 
				var d = document.getElementById("tb");
				for(var i = 1 ;i<d.rows.length;i++){
					d.rows[i].cells[0].innerHTML = i;
				}
			tijiao();
			document.getElementById("fm").submit();
		}
		
	} 
	
	function tijiao(){
		 var jwtb = document.getElementById("tb");
		 var values = "";
		 for(var i = 1;i<jwtb.rows.length;i++){
		 	var row = jwtb.rows[i];
			if(i!=jwtb.rows.length-1){
				values = values +row.cells[1].innerHTML+","+row.cells[2].innerHTML+",";
			}else{
				values = values +row.cells[1].innerHTML+","+row.cells[2].innerHTML;
			}			
		 }
		 document.getElementById("markDate.crdn").value=values;
		 
	}
	var num = 1;
	function changetab(view,info){
		
		var tab1 = document.getElementById("tab1");
		var tab2 = document.getElementById("tab2");
		var tab3 = document.getElementById("tab3");
		
		if(view=="tab1"){	
			tab2.style.display="none";
			tab3.style.display="none";
			tab1.style.display="block";	
			
			sp1.style.background = "url(../resource/img/tabright1.gif) no-repeat right top";
			sp2.style.background = "url(../resource/img/tabright.gif) no-repeat right top";
			sp3.style.background = "url(../resource/img/tabright.gif) no-repeat right top";
		}else if(view=="tab3"){
			tab2.style.display="none";
			tab1.style.display="none";
			tab3.style.display="block";	
			
			sp1.style.background = "url(../resource/img/tabright.gif) no-repeat right top";
			sp2.style.background = "url(../resource/img/tabright.gif) no-repeat right top";
			sp3.style.background = "url(../resource/img/tabright1.gif) no-repeat right top";
		}else if(view=="tab2"){
			tab2.style.display="block";
			tab1.style.display="none";
			tab3.style.display="none";
			
			sp1.style.background = "url(../resource/img/tabright.gif) no-repeat right top";
			sp2.style.background = "url(../resource/img/tabright1.gif) no-repeat right top";
			sp3.style.background = "url(../resource/img/tabright.gif) no-repeat right top";

		}
	}
	
	function subLength(obj,length,start,end,ob){
		if(ob=="int"){
			intOnly(obj);
			
		}else if(ob=="num"){
			numberOnly(obj);
			
		}
	 	var objvalue = obj.value
		if(objvalue.length>length){
			obj.value = objvalue.substring(0,length);
		}else if(parseFloat(objvalue)>=end | parseFloat(objvalue)<start){
			alert("数字范围："+start+"到"+end);
			obj.value = "00"; //objvalue.substring(0,length-1);
		}
	}
//	function intOnly() {
//	if (!((window.event.keyCode >= 48) && (window.event.keyCode <= 57))) {
//		window.event.keyCode = 0;
//		alert("请输入整数数字!");
//	}
//}
//function numberOnly() {
//	if (!(((window.event.keyCode >= 48) && (window.event.keyCode <= 57)) || (window.event.keyCode == 13) || (window.event.keyCode == 46))) {
//		window.event.keyCode = 0;
//		alert("请输入数字!");
//	}
//}